<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Detail: time/service_time_scheduler.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Detail
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_f6227287712d84441d1f97cc74cea9a5.html">time</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">service_time_scheduler.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="service__time__scheduler_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment">// #ifndef SERVICE_TIME_SCHEDULER_HPP</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment">// #define SERVICE_TIME_SCHEDULER_HPP</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160; </div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160; </div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include &quot;box/service_context.hh&quot;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#include &quot;scheduler/scheduler.hh&quot;</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="service__tool_8hpp.html">service_tool.hpp</a>&quot;</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="singleton_8hpp.html">singleton.hpp</a>&quot;</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160; </div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160; </div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="keyword">namespace </span>guild_service {</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="keyword">namespace </span>common {</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160; </div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="classguild__service_1_1common_1_1service__time__scheduler.html">   39</a></span>&#160;<span class="keyword">class </span><a class="code" href="classguild__service_1_1common_1_1service__time__scheduler.html">service_time_scheduler</a> : <span class="keyword">public</span> <a class="code" href="classguild__service_1_1common_1_1service__tool.html">service_tool</a> {</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160; <span class="keyword">public</span>:</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;  <span class="keyword">using</span> service_context_type = kratos::service::ServiceContext;</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;  <span class="keyword">using</span> time_scheduler_ptr_type = kratos::service::SchedulePtr;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;  <span class="keyword">using</span> time_scheduler_callback_type = kratos::service::SchedulerCallback;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160; </div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  <a class="code" href="classguild__service_1_1common_1_1service__time__scheduler.html">service_time_scheduler</a>() : <a class="code" href="classguild__service_1_1common_1_1service__tool.html">service_tool</a>() {}</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160; </div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;  <a class="code" href="classguild__service_1_1common_1_1service__time__scheduler.html">service_time_scheduler</a>(service_context_type *context)</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;      : <a class="code" href="classguild__service_1_1common_1_1service__tool.html">service_tool</a>(),</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        m_time_scheduler_ptr(std::move(context-&gt;new_scheduler())) {}</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160; </div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;  <span class="keyword">virtual</span> ~<a class="code" href="classguild__service_1_1common_1_1service__time__scheduler.html">service_time_scheduler</a>() = <span class="keywordflow">default</span>;</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160; </div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160; <span class="keyword">public</span>:</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;  <span class="keyword">const</span> time_scheduler_ptr_type &amp;operator-&gt;()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    <span class="keywordflow">return</span> m_time_scheduler_ptr;</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;  }</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160; </div>
<div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="classguild__service_1_1common_1_1service__time__scheduler.html#ab20ee526e30a541110e469f9ca901bae">   64</a></span>&#160;  std::size_t <a class="code" href="classguild__service_1_1common_1_1service__time__scheduler.html#ab20ee526e30a541110e469f9ca901bae">update</a>(std::time_t ms) {</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    <span class="keywordflow">return</span> m_time_scheduler_ptr-&gt;do_schedule(ms, 10);</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;  }</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160; </div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160; <span class="keyword">private</span>:</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;  time_scheduler_ptr_type m_time_scheduler_ptr;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;};</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160; </div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;}  <span class="comment">// namespace common</span></div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160; </div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="preprocessor">#define ServiceTimeSchedulerSingleton(...) \</span></div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;<span class="preprocessor">  (*common::singleton&lt;common::service_time_scheduler&gt;::instance(__VA_ARGS__))</span></div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160; </div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="keyword">inline</span> <span class="keyword">static</span> std::uint64_t time_schedule(</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    std::time_t duration,</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;    common::service_time_scheduler::time_scheduler_callback_type cb,</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    std::uint64_t udata) {</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  <span class="keywordflow">return</span> ServiceTimeSchedulerSingleton()-&gt;schedule(duration, cb, udata);</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;}</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160; </div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;}  <span class="comment">// namespace guild_service</span></div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160; </div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<span class="comment">// #endif  // SERVICE_TIME_SCHEDULER_HPP</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclassguild__service_1_1common_1_1service__time__scheduler_html"><div class="ttname"><a href="classguild__service_1_1common_1_1service__time__scheduler.html">guild_service::common::service_time_scheduler</a></div><div class="ttdoc">服务定时器类</div><div class="ttdef"><b>Definition:</b> service_time_scheduler.hpp:39</div></div>
<div class="ttc" id="aclassguild__service_1_1common_1_1service__tool_html"><div class="ttname"><a href="classguild__service_1_1common_1_1service__tool.html">guild_service::common::service_tool</a></div><div class="ttdoc">服务使用计数类</div><div class="ttdef"><b>Definition:</b> service_tool.hpp:34</div></div>
<div class="ttc" id="asingleton_8hpp_html"><div class="ttname"><a href="singleton_8hpp.html">singleton.hpp</a></div><div class="ttdoc">单例模板</div></div>
<div class="ttc" id="aservice__tool_8hpp_html"><div class="ttname"><a href="service__tool_8hpp.html">service_tool.hpp</a></div><div class="ttdoc">服务使用计数</div></div>
<div class="ttc" id="aclassguild__service_1_1common_1_1service__time__scheduler_html_ab20ee526e30a541110e469f9ca901bae"><div class="ttname"><a href="classguild__service_1_1common_1_1service__time__scheduler.html#ab20ee526e30a541110e469f9ca901bae">guild_service::common::service_time_scheduler::update</a></div><div class="ttdeci">std::size_t update(std::time_t ms)</div><div class="ttdef"><b>Definition:</b> service_time_scheduler.hpp:64</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.20
</small></address>
</body>
</html>
